/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package com.deliccio.entitys;

import java.io.Serializable;
import java.lang.reflect.Method;

import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

import com.deliccio.connect.Entidad;

/**
 *
 * @author DaN
 */
@Entity
@Table(name = "columna")
public class Columna implements Entidad,  Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "idcolumna", nullable = false)
    private Integer id;
    @Column(name = "nombre", length = 20)
    private String nombre;
    @Column(name = "codigo", length = 20)
    private String codigo;
    @Column(name = "visible")
    private Boolean visible;
    @Column(name = "titulo", length = 20)
    private String titulo;
    @Column(name = "ancho")
    private Integer ancho;
    
    @JoinColumn(name = "idgrid", referencedColumnName = "idgrid")
    @ManyToOne
    private Grid grid;
    @Column(name = "mapping")
    private Boolean mapping;
    
    public Columna() {
    }

    public Columna(Integer id,String nombre,String codigo,Boolean visible,String titulo,Integer ancho,Boolean mapping){
		super();
		this.id=id;
		this.nombre=nombre;
		this.codigo=codigo;
		this.visible=visible;
		this.titulo=titulo;
		this.ancho=ancho;
		this.mapping=mapping;
	}





	public Columna(Integer id,String nombre,String codigo,Boolean visible,String titulo,Integer ancho){
		super();
		this.id=id;
		this.nombre=nombre;
		this.codigo=codigo;
		this.visible=visible;
		this.titulo=titulo;
		this.ancho=ancho;
	}

	public Columna(int i,String string,String string2,boolean b,String string3,int j){
		
	}

	public Integer getId(){
		return id;
	}



	public void setId(Integer id){
		this.id=id;
	}



	public Boolean getMapping(){
		return mapping;
	}




	public void setMapping(Boolean mapping){
		this.mapping=mapping;
	}




	public String getNombre() {
        return nombre;
    }

    public void setNombre(String nombre) {
        this.nombre = nombre;
    }

    public String getCodigo() {
        return codigo;
    }

    public void setCodigo(String codigo) {
        this.codigo = codigo;
    }
    
    public Boolean getVisible(){
		return visible;
	}

	public void setVisible(Boolean visible){
		this.visible=visible;
	}
	
	public String getTitulo() {
        return titulo;
    }

    public void setTitulo(String titulo) {
        this.titulo = titulo;
    }

    public Integer getAncho() {
        return ancho;
    }

    public void setAncho(Integer ancho) {
        this.ancho = ancho;
    }

    public Grid getGrid() {
        return grid;
    }

    public void setGrid(Grid grid) {
        this.grid = grid;
    }


    @SuppressWarnings("rawtypes")
  	@Override
  	public String toString() {
  		String toString = "[";
  		@SuppressWarnings("unused")
  		String campo,iscampo = "";
  		try {
  			Class clase = this.getClass();
  			Method[] metodos = clase.getDeclaredMethods();
  			for (Method met:metodos) {					
  				if (met.getName().indexOf("get") >= 0) {
  					toString += met.getName()+"="+met.invoke(this, null)+" - ";
  				}
  			}								
  			toString+="]";
  		} catch (Exception e) {			
  			System.out.println(e);
  		}
  		return toString;
  	}

}
